#pragma once

/*
* Functions to print text and manage the shell's font
* Dependencies: bzbshell
*/

#include <iostream>
#include <cstdlib>

#include "../bzbterm/termcolor.h"

namespace bzbio {


/*
 * Prints all the parameters to the screen, then a newline
 */

// Forward declaration
template<typename First, typename ... Many>
void c_println(const First &arg, const Many &... rest);


inline void println() {
	std::cout << std::endl;
}

template<typename First, typename ... Many>
inline void println(const First &arg, const Many &... rest) {
	std::cout << arg;
	println(rest...);
}

// Specialized template for escape sequences
// Automatically resets colors
template<typename ... Many>
inline void println(bzbterm::EscSeq e, const Many &... rest) {
	std::cout << e;
	c_println(rest...);
}


/*
 * Prints all the parameters to the screen with the specified
 * color escape sequence, then a reset escape sequence and a newline
 */

inline void c_println() {
	std::cout << bzbterm::style::reset << std::endl;
}

inline void c_println(bzbterm::EscSeq color) {
	std::cout << color << bzbterm::style::reset << std::endl;
}

template<typename First, typename ... Many>
inline void c_println(const First &arg, const Many &... rest) {
	std::cout << arg;
	c_println(rest...);
}

template<typename First, typename ... Many>
inline void c_println(bzbterm::EscSeq color, const Many &... rest) {
	std::cout << color;
	c_println(rest...);
}


/*
 * Prints all the parameters to the screen
 */

inline void print() {
}

template<typename First, typename ... Many>
inline void print(const First &arg, const Many &... rest) {
	std::cout << arg;
	print(rest...);
}


/*
 * Prints a red message and then exits returning <code>
 */

inline void exit_on_error(const std::string &message, const int &code = 1) {

	println(bzbterm::fg::red, message, bzbterm::fg::reset);
	exit(code);
}


/*
 * Prints Balzebub's logo
 */

inline void print_logo() {

	println(" ____              ___                   __               __        \n",
			"/\\  _`\\           /\\_ \\                 /\\ \\             /\\ \\       \n",
			"\\ \\ \\L\\ \\     __  \\//\\ \\    ____      __\\ \\ \\____  __  __\\ \\ \\____  \n",
			" \\ \\  _ <'  /'__`\\  \\ \\ \\  /\\_ ,`\\  /'__`\\ \\ '__`\\/\\ \\/\\ \\\\ \\ '__`\\ \n",
			"  \\ \\ \\L\\ \\/\\ \\L\\.\\_ \\_\\ \\_\\/_/  /_/\\ ",
			" __/\\ \\ \\L\\ \\ \\ \\_\\ \\\\ \\ \\L\\ \\\n",
			"   \\ \\____/\\ \\__/.\\_\\/\\____\\ /\\____\\ \\____\\\\ \\_,__/\\ \\____/ \\ \\_,__/\n",
			"    \\/___/  \\/__/\\/_/\\/____/ \\/____/\\/____/ \\/___/  \\/___/   \\/___/ ");
}


}
